package com.test.langchain4j.config;

import com.test.langchain4j.service.LawAssistant;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA.
 *
 * @description:
 * @author: liuziyang
 * @since: 2025/8/1 08:29
 * @modifiedBy:
 * @version: 1.0
 */
@Configuration
public class LLMConfig {
  @Bean
  public ChatModel chatModel() {
    return OpenAiChatModel.builder()
        .apiKey(System.getenv("qwen-api-key"))
        .modelName("qwen-long")
        .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
        .build();
  }

  @Bean
  public LawAssistant lawAssistant(ChatModel chatModel) {
    return AiServices.create(LawAssistant.class, chatModel);
  }
}
